<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>对数组排序</title>
	</head>
	<body>
		<script>
			var arr = [1,2,3,100,200,300,10,20,30];
			var f = function(a,b){
				if(a>b){
					return 1;
				}else if(a<b){
					return -1;
				}else{
					return 0;
				}
			}
			console.log(arr.sort(f));
		</script>
	</body>
</html>
